//package aspectLog;
//
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.annotation.*;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//import services.log.TableEditLogServices;
//import util.JsonUtil;
//import wt.entity.log.TableEditLogWithBLOBs;
//
//import javax.servlet.http.HttpServletRequest;
//import java.lang.reflect.Method;
//import java.util.Date;
//
//@Component
//@Aspect
//public class PrintSystemLogAspect11 {
//    @Autowired
//    TableEditLogServices   tableEditLogServices;
//
//    private static Logger log = LoggerFactory.getLogger(PrintSystemLogAspect11.class);
//    private long startTime = 0L;
//
//
//    /**
//     * Service层切点
//     */
//    @Pointcut("execution(* aspect.IBaseServicesLog.*(..))")
//    public void serviceAspect() {
//    }
//
//
//    @Before("serviceAspect()")
//    public void before(JoinPoint joinPoint) {
//        startTime = System.currentTimeMillis();
//        System.out.println(">>>>>>>>>>>>>>>>>>>>>>@Before>>>>>>>>>>>>>>>>>>>>>>>");
//
//
//    }
//
//    @AfterThrowing("serviceAspect()")
//    public void afterThrowing(JoinPoint joinPoint) {
//        System.out.println(">>>>>>>>>>>>>> @AfterThrowing >>>>>>>>>>>>>>>>>>>>>>>>");
//    }
//
//
//    /**
//     * doServiceLog:获取注解参数，记录日志.
//     * @param joinPoint
//     * @throws Exception
//     */
//    @AfterReturning("serviceAspect()")
//    public void afterReturning(JoinPoint joinPoint) throws Exception {
//        log.info("日志记录");
//        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
//        String uri = request.getRequestURI();
//        String ip = request.getRemoteAddr();
//        String httpMethod = request.getMethod();
//        String httpParam = JsonUtil.obj2Json(request.getParameterMap());
//        long timeConsume = System.currentTimeMillis() - startTime;
//        String methodName = joinPoint.getSignature().getName();
//        short operateType = -1; //操作表类型 -1不清楚  0新增 1查询  2修改  3删除  4登录 5退出
//        if (methodName.equals("recordDeleteLog")) {
//            operateType = 3;
//        } else if (methodName.equals("recordUpdateLog")) {
//            operateType = 2;
//        } else if (methodName.equals("recordInsertLog")) {
//            operateType = 0;
//        } else {
//            log.error("记录类条 操作类型 未知的记录");
//        }
//
//
//        TableEditLogWithBLOBs tableEditLog=new TableEditLogWithBLOBs();
//        tableEditLog.setUri(uri);
//        tableEditLog.setIp(ip);
//        tableEditLog.setHttpMethod(httpMethod);
//        tableEditLog.setHttpParam(httpParam);
//        tableEditLog.setConsumeTime((double)timeConsume);
//        tableEditLog.setRequestTime(new Date());
//        tableEditLog.setTableName(getTableName(joinPoint));
//        tableEditLog.setTableOperation(operateType);
//        tableEditLog.setTableData(tableParams(joinPoint));
//        tableEditLogServices.insertSelective(tableEditLog);
//
//        System.out.println("uri:" + uri);
//        System.out.println("ip:" + ip);
//        System.out.println("httpMethod:" + httpMethod);
//        System.out.println("httpParam:" + httpParam);
//        System.out.println("timeConsume:" + timeConsume);
//        System.out.println("time:" + new Date());
//        System.out.println("operationType:" + operateType);
//        System.out.println("tableName:" + getTableName(joinPoint));
//        System.out.println("tableParam:" + tableParams(joinPoint));
//
//
//    }
//
//
//    private String getTableName(JoinPoint joinPoint) throws Exception {
//        String targetName = joinPoint.getTarget().getClass().getName();
//        Class targetClass = Class.forName(targetName);
//        Method m = targetClass.getDeclaredMethod("getTableName");
//        String tableName = (String) m.invoke(joinPoint.getTarget());
//        return tableName;
//    }
//
//    private String tableParams(JoinPoint joinPoint) throws Exception {
//        Object[] arguments = joinPoint.getArgs();
//        String params = JsonUtil.obj2Json(arguments);
//        return params;
//    }
//
//
//
//}